home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_059 / browser / pf.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  696b  |  44 lines

  1. /*
  2.  
  3.  
  4.       Parsefile() is a modified word count from K&R page 18
  5.  
  6.                               M.E.S.    87-01-11
  7.  
  8. */
  9. #include "browser.h"
  10. #include <stdio.h>
  11. #include <ctype.h>
  12.  
  13. #define  YES   1
  14. #define   NO   0
  15.  
  16. struct FStatistics *stats;
  17. FILE *parsefile(fp)
  18. FILE *fp;
  19. {
  20.    int c,nl,nw,nc,inword;
  21.  
  22.  
  23.    inword = NO;
  24.    nl = nw = nc = 0;
  25.    while ((c = getc(fp)) != EOF)
  26.       {
  27.          ++nc;
  28.          if ( c == '\n')    ++nl;
  29.          if ( c == ' ' || c == '\n' || c == '\t')  inword = NO;
  30.          else if (inword == NO)
  31.             {
  32.                inword = YES;
  33.                ++nw;
  34.             }
  35.       }
  36.    stats->bites = nc;
  37.    stats->lines = nl;
  38.    stats->words = nw;
  39.  
  40.    return(fp);
  41. }
  42.  
  43.  
  44.